#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 文件名：13-正则.py

import re

'''str1 = "ab23hhd31s"
pattern1 = r'[0-9]+'

print re.findall(pattern1, str1)'''

'''str1 = "hello word"
pattern1 = r'hello'

m1 = re.match(pattern1, str1)
print m1.group(0)
print m1.span()'''
'''
s1 = "tom"
s2 = "tim"'''
'''s3 = "tioiooimtom"

# 正则表达式[]中的内容或关系，后面的+一个或多个
pattern1 = r't[io]+m'''

'''m1 = re.match(pattern1, s1)
print m1.group(0)

m2 = re.match(pattern1, s2)
print m2.group(0)'''

'''m3 = re.match(pattern1, s3)
print m3.group()
print m3.span()'''


'''str1 = "helloword"
pattern1 = r'^[a-z]+$'

m1 = re.match(pattern1, str1)
print m1.group()
print m1.span()'''

str1 = "344134"
pattern1 = r'^[1-4]+$'

m1 = re.match(pattern1, str1)
print m1.group()
print m1.span()

# r表示原始字符串，不用写转义符了
path = r"d:\newdir"
print path

pfinfo = "pf    2828   8032  "
pattern1 = r'\S+'
# S表明是非空格 s表明是空格
m1 = re.match(pattern1, pfinfo)
print m1.group()
#print m1.span(0)

result = "error: MySQL execute failed! ERROR(1146): Table 'ops.test_mysqldb' doesn't exist"
if re.search("doesn't exist", result):
    print "zhao dao"
else:
    print " mei  zhao dao"